package com.handler.manager;

import com.message.BasePacket;

public abstract class PacketHandler<T extends BasePacket>{
	/**
	 * handler的唯一标识
	 * //TODO cmd名字不合适，但改动后需要改大量代码
	 */
	protected final short cmd;

	protected PacketHandler(short cmd, PacketHandlerManager<T> manager) {
		this.cmd = cmd;
		manager.registerHandler(this);
	}
	
	/**
	 * 业务逻辑入口
	 * @param packet 网络包
	 */
	public abstract BasePacket handle(T packet) throws Exception;

	public short getCmd() {
		return cmd;
	}
}